package com.howie.hmvc.paramparse;

import java.lang.annotation.Annotation;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import lombok.Setter;

import org.apache.log4j.Logger;

import com.howie.hmvc.annotations.Valid;

/**
 * 参数获取器根接口
 * @author dhz
 */
public abstract class AbsParamParse{

	public static final Logger LOG = Logger.getLogger(AbsParamParse.class);
	
	@Setter
	protected String name;
	
	public abstract Object getParamter(HttpServletRequest request,HttpServletResponse response) throws Exception;
	
	public void init(Annotation[] an)throws Exception{
	}
	
	/*
	 * 获取Valid注解
	 * @param an
	 * @return
	 */
	protected Valid getValid(Annotation[] an){
		for(Annotation a : an){
			if(a instanceof Valid){
				return (Valid)a;
			}
		}
		return null;
	}
}
